package com.wxzz.elearing.pay.api.server;

import com.wxzz.elearing.pay.service.IUserTransactionService;
import com.wxzz.elearing.pay.service.IUserWalletService;
import com.wxzz.elearning.common.dto.FeignUserWalletDto;
import com.wxzz.elearning.common.vo.ReturnVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/user-wallet-api")
public class UserWalletApi {

    @Autowired
    private IUserWalletService userWalletService;

    @Autowired
    private IUserTransactionService userTransactionService;

    /**
     * 根据用户id与类型查询用户钱包
     * @param userId
     * @param userType
     * @return
     */
    @RequestMapping(value = "/selectUserWalletByUserIdAndType/{userId}/{userType}", method = RequestMethod.POST)
    public FeignUserWalletDto selectUserWalletByUserIdAndType(@PathVariable Long userId, @PathVariable Integer userType) {
        return userWalletService.selectUserWalletByUserIdAndType(userId, userType);
    }


    /**
     * 平台给予用户赏金
     * @param userId
     * @param orderId
     * @return
     */
    @RequestMapping(value = "/giveAnswers/{userId}/{orderId}", method = RequestMethod.POST)
    public ReturnVO giveAnswers(@PathVariable Long userId,@PathVariable Long orderId) {
        return userTransactionService.giveAnswers(userId, orderId);
    }
}
